﻿using System;

namespace Utility.Helper
{
    public static class DbHelper
    {
        public static string DefaultDbType = "ORACLE";

        public static string SetParmString(string parm, string parmname)
        {
            if (parm == null)
            {
                return parmname + " IS NULL";
            }
            return parmname + " = '" + parm + "'";
        }

        public static string SetParmString<T>(T parm, string parmname)
        {
            if (parm == null)
            {
                return parmname + " IS NULL";
            }
            var type = typeof(T);
            if (type == typeof(Int16))
            {
                return parmname + " = " + parm.ToString();
            }
            if (type == typeof(Int32))
            {
                return parmname + " = " + parm.ToString();
            }
            if (type == typeof(decimal))
            {
                return parmname + " = " + parm.ToString();
            }
            return parmname + " = '" + parm.ToString() + "'";
        }
    }
}